import EmptyRouter from "~/components/EmptyRouter";
import MainLayout from "~/layout/MainLayout";
import FirstLevelRouter from "~/router/FirstLevelRouter";
import Router from "vue-router"
import Vue from "vue";

export const PLATFORM_KEY = 'enterprise';
export const ROOT = '/:' + PLATFORM_KEY;
export const LOGIN = 'login';
export const INDEX = 'index';

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router)
const routers = [
    {
        path: ROOT,
        component: EmptyRouter,
        children: [
            {
                path: LOGIN,
                component: () => import(/* webpackChunkName: "Login" */ '~/views/Login.vue'),
                name: LOGIN
            }, {
                path: INDEX,
                name: INDEX,
                component: () => import("~/views/Index")
            }, {
                path: '',
                component: MainLayout,
                redirect: {
                    name: LOGIN
                },
                children: FirstLevelRouter,
            }
        ],
    }
];

export default routers;
